home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / mail / smailsr2.lha / SMail / src / RCS / main.c,v < prev    next >
Encoding:
Text File  |  1993-11-30  |  36.1 KB  |  1,849 lines

  1. head    2.1;
  2. access;
  3. symbols
  4.     C_2:2.1
  5.     C_1:1.23;
  6. locks; strict;
  7. comment    @ * @;
  8.  
  9.  
  10. 2.1
  11. date    93.11.23.19.58.39;    author Aussem;    state Exp;
  12. branches;
  13. next    1.29;
  14.  
  15. 1.29
  16. date    93.11.23.18.07.35;    author Aussem;    state Exp;
  17. branches;
  18. next    1.28;
  19.  
  20. 1.28
  21. date    93.11.20.23.52.30;    author Aussem;    state Exp;
  22. branches;
  23. next    1.27;
  24.  
  25. 1.27
  26. date    93.11.20.23.28.53;    author Aussem;    state Exp;
  27. branches;
  28. next    1.26;
  29.  
  30. 1.26
  31. date    93.11.20.22.20.50;    author Aussem;    state Exp;
  32. branches;
  33. next    1.25;
  34.  
  35. 1.25
  36. date    93.11.19.00.11.29;    author Aussem;    state Exp;
  37. branches;
  38. next    1.24;
  39.  
  40. 1.24
  41. date    93.11.18.23.16.34;    author Aussem;    state Exp;
  42. branches;
  43. next    1.23;
  44.  
  45. 1.23
  46. date    93.11.13.22.13.10;    author Aussem;    state Exp;
  47. branches;
  48. next    1.22;
  49.  
  50. 1.22
  51. date    93.11.13.21.17.19;    author Aussem;    state Exp;
  52. branches;
  53. next    1.21;
  54.  
  55. 1.21
  56. date    93.11.09.22.41.53;    author Aussem;    state Exp;
  57. branches;
  58. next    1.20;
  59.  
  60. 1.20
  61. date    93.11.04.22.46.25;    author Aussem;    state Exp;
  62. branches;
  63. next    1.19;
  64.  
  65. 1.19
  66. date    93.11.02.19.57.08;    author Aussem;    state Exp;
  67. branches;
  68. next    1.18;
  69.  
  70. 1.18
  71. date    93.10.31.21.41.22;    author Aussem;    state Exp;
  72. branches;
  73. next    1.17;
  74.  
  75. 1.17
  76. date    93.10.31.21.13.09;    author Aussem;    state Exp;
  77. branches;
  78. next    1.16;
  79.  
  80. 1.16
  81. date    93.10.31.17.50.59;    author Aussem;    state Exp;
  82. branches;
  83. next    1.15;
  84.  
  85. 1.15
  86. date    93.10.30.23.50.40;    author Aussem;    state Exp;
  87. branches;
  88. next    1.14;
  89.  
  90. 1.14
  91. date    93.10.30.23.49.15;    author Aussem;    state Exp;
  92. branches;
  93. next    1.13;
  94.  
  95. 1.13
  96. date    93.10.23.22.47.51;    author Aussem;    state Exp;
  97. branches;
  98. next    1.12;
  99.  
  100. 1.12
  101. date    93.10.18.20.38.27;    author Aussem;    state Exp;
  102. branches;
  103. next    1.11;
  104.  
  105. 1.11
  106. date    93.10.17.21.12.27;    author Aussem;    state Exp;
  107. branches;
  108. next    1.10;
  109.  
  110. 1.10
  111. date    93.10.17.18.42.34;    author Aussem;    state Exp;
  112. branches;
  113. next    1.9;
  114.  
  115. 1.9
  116. date    93.10.16.14.56.33;    author Aussem;    state Exp;
  117. branches;
  118. next    1.8;
  119.  
  120. 1.8
  121. date    93.10.10.19.32.34;    author Aussem;    state Exp;
  122. branches;
  123. next    1.7;
  124.  
  125. 1.7
  126. date    93.09.29.13.14.46;    author Aussem;    state Exp;
  127. branches;
  128. next    1.6;
  129.  
  130. 1.6
  131. date    93.09.18.20.23.05;    author Aussem;    state Exp;
  132. branches;
  133. next    1.5;
  134.  
  135. 1.5
  136. date    93.09.18.16.47.47;    author Aussem;    state Exp;
  137. branches;
  138. next    1.4;
  139.  
  140. 1.4
  141. date    93.09.13.22.23.09;    author Aussem;    state Exp;
  142. branches;
  143. next    1.3;
  144.  
  145. 1.3
  146. date    93.09.12.14.35.49;    author Aussem;    state Exp;
  147. branches;
  148. next    1.2;
  149.  
  150. 1.2
  151. date    93.09.10.01.54.39;    author Aussem;    state Exp;
  152. branches;
  153. next    1.1;
  154.  
  155. 1.1
  156. date    93.09.08.16.27.13;    author Aussem;    state Exp;
  157. branches;
  158. next    ;
  159.  
  160.  
  161. desc
  162. @main module of smail
  163. @
  164.  
  165.  
  166. 2.1
  167. log
  168. @Version 2.0 check in
  169. @
  170. text
  171. @/*
  172.  *  main.c
  173.  *
  174.  *  rmail/smail - UUCP mailer with automatic routing.
  175.  *
  176.  *  Christopher Seiwald        /+\
  177.  *  chris@@cbosgd.att.com    +\
  178.  *  January, 1985        \+/
  179.  *
  180.  * This program is free software; you can redistribute it and/or
  181.  * modify it under the terms of the GNU General Public License as
  182.  * published by the Free Software Foundation; either version 2 of
  183.  * the License, or (at your option) any later version.
  184.  *
  185.  * This program is distributed in the hope that it will be useful,
  186.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  187.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  188.  * General Public License for more details.
  189.  *
  190.  * You should have received a copy of the GNU General Public License
  191.  * along with this program; if not, write to the Free Software
  192.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  193.  *
  194.  * $Log: main.c,v $
  195.  * Revision 1.29  1993/11/23  18:07:35  Aussem
  196.  * getmynames() is now start nearly at the start of smail
  197.  * the batch/unbatch BSMTP functions are now in bsmtp.c
  198.  *
  199.  * Revision 1.28  1993/11/20  23:52:30  Aussem
  200.  * changes output for BSMTP de/batching
  201.  *
  202.  * Revision 1.27  1993/11/20  23:28:53  Aussem
  203.  * SMDebug works now
  204.  * smail now detects if the user forget to specified a host in BSMTP batch mode
  205.  *
  206.  * Revision 1.26  1993/11/20  22:20:50  Aussem
  207.  * extended log output
  208.  *
  209.  * Revision 1.25  1993/11/19  00:11:29  Aussem
  210.  * *** empty log message ***
  211.  *
  212.  * Revision 1.24  1993/11/18  23:16:34  Aussem
  213.  * function call for get_config() changed
  214.  * setup_external() insert for open/allocating MUFS/Netsupport library
  215.  *
  216.  * Revision 1.23  1993/11/13  22:13:10  Aussem
  217.  * VERSION integrated
  218.  *
  219.  * Revision 1.22  1993/11/13  21:17:19  Aussem
  220.  * changes getversion to get_programtype()
  221.  * take rmail name from uulib:config
  222.  *
  223.  * Revision 1.21  1993/11/09  22:41:53  Aussem
  224.  * cosmetic changes
  225.  *
  226.  * Revision 1.20  1993/11/04  22:46:25  Aussem
  227.  * smail searches now only to To:/Cc:/Bcc: without a leading space
  228.  *
  229.  * Revision 1.19  1993/11/02  19:57:08  Aussem
  230.  * atexit() insert
  231.  *
  232.  * Revision 1.18  1993/10/31  21:41:22  Aussem
  233.  * cosmetic changes
  234.  *
  235.  * Revision 1.17  1993/10/31  21:13:09  Aussem
  236.  * bigger stack size
  237.  *
  238.  * Revision 1.16  1993/10/31  17:50:59  Aussem
  239.  * cosmetic changes in help text
  240.  *
  241.  * Revision 1.15  1993/10/30  23:50:40  Aussem
  242.  * Version string corrected
  243.  *
  244.  * Revision 1.14  1993/10/30  23:49:15  Aussem
  245.  * stack size via __stacksize set to 20000 bytes
  246.  * Version string updated
  247.  *
  248.  * Revision 1.13  1993/10/23  22:47:51  Aussem
  249.  * the file for bsmtp options are taken from uulib:config
  250.  *
  251.  * Revision 1.12  1993/10/18  20:38:27  Aussem
  252.  * batch option implemtended
  253.  *
  254.  * Revision 1.11  1993/10/17  21:12:27  Aussem
  255.  * compress and freeze commands are taken from uulib:config (if present)
  256.  * smail converts the smtp mail to "normal" format and
  257.  * then deliver via rmail
  258.  *
  259.  * Revision 1.10  1993/10/17  18:42:34  Aussem
  260.  * reading a file with -f works now
  261.  * uncompressing a mail, if the programs is rfsmtp or rcsmtp works
  262.  *
  263.  * Revision 1.9  1993/10/16  14:56:33  Aussem
  264.  * -M option implemented
  265.  *
  266.  * Revision 1.8  1993/10/10  19:32:34  Aussem
  267.  * Bcc: lines are now supported
  268.  *
  269.  * Revision 1.7  1993/09/29  13:14:46  Aussem
  270.  * If smail calls smail again, it uses first the uulib:config entry for Sendmail
  271.  * and if not exists sendmail
  272.  *
  273.  * Revision 1.6  1993/09/18  20:23:05  Aussem
  274.  * the cc line can now be parsed from cmdline and from file
  275.  *
  276.  * Revision 1.5  1993/09/18  16:47:47  Aussem
  277.  * insert GNU license text in the header
  278.  *
  279.  * Revision 1.4  1993/09/13  22:23:09  Aussem
  280.  * test whether MaxRMailLen exists and set the global variable
  281.  *
  282.  * Revision 1.3  1993/09/12  14:35:49  Aussem
  283.  * SMDebug != 0 will activate verbose output
  284.  *
  285.  * Revision 1.2  1993/09/10  01:54:39  Aussem
  286.  * new support for grepping the To: line from mailbody with grep_toline()
  287.  * for new support for wCNews styled logfile cmd-line options enabled
  288.  * and rmail check (only if we are not rmail grep the To: line)
  289.  * react as rmail can be enabled via -r cmd-line option
  290.  *
  291.  * Revision 1.1  1993/09/08  16:27:13  Aussem
  292.  * Initial revision
  293.  *
  294.  *
  295.  */
  296.  
  297. static char     *rcsid="$Id: main.c,v 1.29 1993/11/23 18:07:35 Aussem Exp Aussem $";
  298.  
  299. /*
  300. **
  301. **  usage:      rmail [options] address...
  302. **        smail [options] address...
  303. */
  304.  
  305. #include    <stdio.h>
  306. #include    <stdlib.h>
  307. #include    <ctype.h>
  308. #include    "defs.h"
  309.  
  310. static const char version_string[]="$VER: SMail "SMAIL_VERSION" Amiga Version ("__DATE__","__TIME__")";
  311. const char version[]="AmigaSmail"SMAIL_VERSION;
  312.  
  313. extern char return_receipt[];
  314. extern char checkuserfile[];
  315. extern char prgtype_string[];
  316. extern enum eclass debuglevel;
  317.  
  318. /* should be large enough */
  319. long __stack=80000L;
  320.  
  321. static char ** mk_argv(char * , int * );
  322. static char ** cp_argv(char ** , char ** , int , int );
  323.  
  324.  
  325. static const char *errortext="\
  326.  usage:      rmail [options] address...\n\
  327.     smail [options] address...\n\
  328.  options:\n\
  329.     -D     batch BSMTP mails for host specified -h \n\
  330.     -d     debug - verbose and don't invoke mailers.\n\
  331.     -v        verbose - just verbose.\n\
  332.     -A        print mapped addresses.  don't invoke mailers.\n\
  333.     -B        use BSMTP (batch simple mail transport protocol) for transfer.\n\
  334.     -h hostname    set hostname\n"
  335. #ifdef MYDOM
  336. "    -H hostdomain    set hostdomain (default hostname."MYDOM")\n"
  337. #else
  338. "    -H hostdomain    set hostdomain (default hostname)\n"
  339. #endif
  340. "    -p pathfile    path database filename\n\
  341.     -o        force routing of host!address\n\
  342.     -O        reroute even explicit path!user\n\
  343.     -l        user@@domain goes to local mailer\n\
  344.     -L        all mail goes local\n\
  345.     -C        Consult the paths file for the cost of the path\n\
  346.     -r        running in rmail mode\n\
  347.     -M        don't return mails, if we can't deliver them\n\
  348.     -q number    mail queueing cost threshold\n\
  349.     -m number    limit on number of uux_noqueue jobs\n\
  350.     -u string    string of flags for uux\n\
  351.     -t address    address  to send the mail\n\
  352.     -s subject    subject of the mail\n\
  353.     -R realname    realname of the user\n\
  354.     -f address    name to substitute in From: line\n\
  355.     -c address    name to substitute in cc: line \n\
  356.     -b address    name to substitute in Bcc: line \n\
  357.     -F file        mail-file to spool\n"
  358. #ifndef SENDMAIL
  359. "    -a aliasfile    aliases filename\n"
  360. #endif
  361. "    -n namelist    list of full names for simple aliases\n";
  362.  
  363. int exitstat = 0;        /* exit status, set by resolve, deliver    */
  364.  
  365. enum edebug debug     = NO;    /* set by -d or -v option        */
  366. enum ehandle handle   = HANDLE;    /* which mail we can handle, see defs.h    */
  367. enum erouting routing = ROUTING;/* to route or not to route, see defs.h */
  368.  
  369. char passwdfile[SMLBUF]   = "getty:passwd";
  370. char logfile[SMLBUF]   = LOG;
  371. char maillogfile[SMLBUF]   = MAILLOG;
  372. char sentfile[SMLBUF]   = RECORD;
  373. char hostname[SMLBUF]   = "";    /* set by -h, defaults in defs.h     */
  374. char hostdomain[SMLBUF] = "";    /* set by -H, defaults in defs.h     */
  375. char hostuucp[SMLBUF] = "";    /* built with hostname+".UUCP"         */
  376. int  cc_index    = -1;        /* index starting Cc: in the to-arguments vector */
  377. int  bcc_index    = -1;       /* index starting Bcc: in the to-arguments vector */
  378. char *subject    = NULL;       /* subject of the mail         */
  379. char *realname   = NULL;      /* realname of the user    */
  380. char *pathfile   = PATHS;       /* or set by -p             */
  381. char *uuxargs    = NULL;        /* or set by -u                */
  382. int  maxrmaillen = 0;         /* maximal rmail length */
  383. char smailname[SMLBUF] = "sendmail"; /* name of smail */
  384. char rmailname[SMLBUF] = "rmail"; /* name of rmail */
  385. char bsmtp_sites[SMLBUF]="uulib:mail/bsmtp_sites";
  386. char argv0[SMLBUF] = "smail"; /* argv[0] */
  387.  
  388. char *aliasfile =
  389. #ifdef ALIAS
  390.         ALIAS;        /* or set by -a                */
  391. #else
  392.         NULL;
  393. #endif
  394.  
  395. char *fnlist    =
  396. #ifdef FULLNAME
  397.         FULLNAME;    /* or set by -n                */
  398. #else
  399.         NULL;
  400. #endif
  401.  
  402. int  queuecost  = QUEUECOST;    /* or set by -q    */
  403. char *from_addr = NULL;        /* or set by -F        */
  404. int  maxnoqueue = MAXNOQUEUE;    /* or set by -m    */
  405. int  receipt = 1;
  406. int  returnmail  = 1; /* or set by -M                */
  407. int  getcost    =
  408. #ifdef GETCOST
  409.         1;    /* get cost of path even if not routing */
  410. #else
  411.         0;
  412. #endif
  413.  
  414. char *spoolfile = NULL;        /* name of the file containing letter   */
  415. FILE *spoolfp;            /* file pointer to spoolfile        */
  416. int  spoolmaster = 0;        /* indicates 'control' of spoolfile     */
  417.  
  418. void spool();
  419.  
  420. int asrmail;            /* invoked as rmail (CMK) */
  421. int bsmtp=0;         /* do BSMTP */
  422. int checkuser=0;     /* check whether a user is allowed to mail via UUCP */
  423. FILE *mystdin=stdin;
  424.  
  425. /*
  426. **
  427. **  rmail/smail: mail stdin letter to argv addresses.
  428. **
  429. **  After processing command line options and finding our host and domain
  430. **  names, we map addresses into <host,user,form,cost> sets.  Then we deliver.
  431. **
  432. */
  433. main(argc, argv)
  434. int argc;
  435. char *argv[];
  436. {
  437.     char *hostv[MAXARGS];        /* UUCP neighbor         */
  438.     char *userv[MAXARGS];        /* address given to host     */
  439.     int  costv[MAXARGS];           /* cost of resolved route    */
  440.     enum eform formv[MAXARGS];    /* invalid, local, or uucp     */
  441.     char cc[SMLBUF] = "";      /* cc-line from the command line */
  442.     char bcc[SMLBUF] = "";      /* bcc-line from the command line */
  443.     char *p;
  444.     int c;
  445.     int  printaddr  = 0;        /* or set by -A            */
  446.     int nargc;
  447.     char **nargv, **alias();
  448.    char to[BIGBUF]="";
  449.     char **to_argv=NULL,**cc_argv=NULL,**bcc_argv=NULL;
  450.     int to_argc=0;
  451.    int deliver_batch=0;
  452.    char compress[SMLBUF]="compress";
  453.    char rsmtp_cmd[SMLBUF]="rcsmtp";
  454.  
  455.     char *optstr = "BCDdvArMoOlLH:h:c:b:p:u:q:a:n:m:F:f:s:t:R:";
  456.     extern char *optarg;
  457.     extern int optind;
  458.    extern void kill_external(void);
  459.    extern int  setup_external(void);
  460.  
  461. /* 
  462. ** install atexit() fkt 
  463. */
  464.    atexit(kill_external);
  465.  
  466. /*
  467. ** setup external libraries
  468. */
  469.    if(!setup_external())
  470.        exit(10);
  471.  
  472. /*
  473. ** get the program type
  474. */
  475.    set_programtype();
  476.    strcpy(argv0,argv[0]);
  477.  
  478. /*
  479. **  Get our default hostname and hostdomain.
  480. */
  481.     getmynames();
  482.  
  483. /*
  484. ** See whether we are started with -raw options
  485. */
  486. for(c=1;c<argc;c++)
  487.     if(strcmp(argv[c],"-raw")==0)
  488.         {
  489.         argv[c][0]='-';
  490.         argv[c][1]='v';
  491.         argv[c][2]='\0';
  492.       print_error(WARNING,"you call smail with the unsupported and ignored -raw option\n",argv[0]);
  493.         }
  494.  
  495. /*
  496. **  see if we aren't invoked as rmail
  497. */
  498.     if(stricmp(argv0,rmailname)!=0 ) {
  499.         handle = ALL;
  500.         asrmail = 0;        /* CMK */
  501.     } else
  502.         asrmail = 1;
  503.  
  504.     if(stricmp(argv0,"rsmtp")==0 )
  505.       {
  506.         asrmail = 1;
  507.         bsmtp=1;
  508.         }
  509.     if(stricmp(argv0,"rfsmtp")==0 )
  510.       {
  511.         asrmail = 1;
  512.         bsmtp=1;
  513.         }
  514.     if(stricmp(argv0,"rcsmtp")==0 )
  515.       {
  516.         asrmail = 1;
  517.         bsmtp=1;
  518.         }
  519.  
  520. /*
  521. **  Process command and config line arguments
  522. */
  523.    p=get_config("SMBsmtpSites","uulib:mail/bsmtp_sites",2);
  524.    if(p)
  525.       strcpy(bsmtp_sites,p);
  526.    p=get_config("SMBsmtpCmd","rcsmtp",2);
  527.    if(p)
  528.       strcpy(rsmtp_cmd,p);
  529.    p=get_config("SMCompress","compress",2);
  530.    if(p)
  531.       strcpy(compress,p);
  532.    p=get_config("SMDebug","0",2);
  533.    if(p)
  534.        debuglevel=atoi(p);
  535.    p=get_config("MaxRMailLen","0",2);
  536.    if(p)
  537.        maxrmaillen=atoi(p);
  538.    p=get_config("SMRerouting","0",2);
  539.    if(p)
  540.        switch(atoi(p))
  541.        {
  542.        default:
  543.        case 0:routing=REROUTE;        /* route C, B, or A (whichever works); set by -R */
  544.                break;
  545.        case 1:routing=ALWAYS;        /* route A always; set by -r */
  546.                break;
  547.        case 2:routing=JUSTDOMAIN;    /* route A if A is a domain */
  548.                break;
  549.        }
  550.    p=get_config("SMHandle","0",2);
  551.    if(p)
  552.        switch(atoi(p))
  553.        {
  554.        default:
  555.        case 0:handle=ALL;
  556.                break;
  557.        case 1:handle=JUSTUUCP;
  558.                break;
  559.        case 2:handle=NONE;
  560.                break;
  561.        }
  562.    if(get_config("SMGetcost","No",0))
  563.        getcost=1;
  564.    else
  565.        getcost=0;
  566.    if(get_config("SMReceipt","Yes",0))
  567.        receipt=1;
  568.    else
  569.        receipt=0;
  570.    if(get_config("SMCheckuser","No",0))
  571.        checkuser=1;
  572.    else
  573.        checkuser=0;
  574.    p=get_config("SMCheckfile","uulib:mail/checkuser",2);
  575.    if(p)
  576.       strcpy(checkuserfile,p);
  577.    p=get_config("SMLogfile","uuspool:logfile",2);
  578.    if(p)
  579.       strcpy(logfile,p);
  580.    p=get_config("SMMaillogfile","uulib:mail/logfile",2);
  581.    if(p)
  582.       strcpy(maillogfile,p);
  583.    p=get_config("SMPasswd","getty:passwd",2);
  584.    if(p)
  585.       strcpy(passwdfile,p);
  586.    p=get_config("SMSentlog","nil:",2);
  587.    if(p)
  588.       strcpy(sentfile,p);
  589.    p=get_config("SMFullname","uulib:mail/fullnames",2);
  590.    if(p)
  591.       fnlist=strdup(p);
  592.    p=get_config("SMPath","uulib:mail/paths",2);
  593.    if(p)
  594.       pathfile=strdup(p);
  595.    p=get_config("SMAlias","uulib:mail/aliases",2);
  596.    if(p)
  597.       aliasfile=strdup(p);
  598.    p=get_config("Sendmail","sendmail",2);
  599.    if(p)
  600.       strcpy(smailname,p);
  601.    p=get_config("Rmail","rmail",2);
  602.    if(p)
  603.       strcpy(rmailname,p);
  604.  
  605.     while ((c = getopt(argc, argv, optstr)) != EOF) {
  606.         switch ( c ) {
  607.         case 'B': bsmtp      = 1;         break;
  608.         case 'D': deliver_batch = 1;         break;
  609.         case 'd': debug      = YES; break;
  610.         case 'v': debug      = VERBOSE; break;
  611.         case 'A': printaddr  = 1;         break;
  612.         case 'f': from_addr  = optarg;        break;
  613.         case 'o': routing    = ALWAYS;        break;
  614.         case 'O': routing    = REROUTE;        break;
  615.         case 'l': handle     = JUSTUUCP;    break;
  616.         case 'L': handle     = NONE;        break;
  617.         case 'r': asrmail    = 1;        break;
  618.         case 'M': returnmail = 0;        break;
  619.         case 'F': spoolfile  = optarg;        break;
  620.         case 'p': pathfile   = optarg;         break;
  621.         case 'u': uuxargs    = optarg;         break;
  622.         case 'a': aliasfile  = optarg;         break;
  623.         case 'n': fnlist     = optarg;         break;
  624.         case 's': subject    = optarg;        break;
  625.         case 't': strcat(to,optarg);strcat(to," ");break;
  626.         case 'c': strcat(cc,optarg);strcat(cc," ");break;
  627.         case 'b': strcat(bcc,optarg);strcat(bcc," ");break;
  628.         case 'R': realname   = optarg;        break;
  629.         case 'H': (void) strcpy(hostdomain, optarg);    break;
  630.         case 'h': (void) strcpy(hostname, optarg);     break;
  631.         case 'm': if(isdigit(*optarg)) {
  632.                   maxnoqueue = atoi(optarg);
  633.               }
  634.               break;
  635.         case 'C': getcost     = 1;        break;
  636.         case 'q': if(isdigit(*optarg)) {
  637.                   queuecost = atoi(optarg);
  638.               }
  639.               break;
  640.         }
  641.     }
  642.  
  643.   /* if we are started as unbatcher for BSMTP mails */
  644.   if(asrmail && bsmtp)
  645.       {
  646.    exit(unbatch_smtp(spoolfile,argv0[1]));
  647.    }
  648.  
  649.   /* if we are started as batcher for BSMTP mails */
  650.   if(deliver_batch)
  651.   {
  652.    exit(batch_smtp(compress,rsmtp_cmd));
  653.   }
  654.  
  655.   /* only search To: lines, if we are not in
  656.      rmail mode and spoolfile!=NULL */
  657.   if(spoolfile && !asrmail)
  658.     {
  659.     char *ptr;
  660.     FILE *fp=fopen(spoolfile,"r");
  661.  
  662.    if(fp)
  663.        {
  664.         ptr=grep_toline(fp,"To:");
  665.        if(ptr)
  666.            strcat(to,ptr);
  667.         ptr=grep_toline(fp,"Cc:");
  668.        if(ptr)
  669.            strcat(cc,ptr);
  670.         ptr=grep_toline(fp,"Bcc:");
  671.        if(ptr)
  672.            strcat(bcc,ptr);
  673.        fclose(fp);
  674.        }
  675.     }
  676.  
  677.  
  678.   /* only search To: lines, if we are not in
  679.      rmail mode and mystdin!=NULL */
  680.   if(mystdin && !asrmail)
  681.     {
  682.     char *ptr;
  683.  
  684.     ptr=grep_toline(mystdin,"To:");
  685.    if(ptr)
  686.        strcat(to,ptr);
  687.     ptr=grep_toline(mystdin,"Cc:");
  688.    if(ptr)
  689.        strcat(cc,ptr);
  690.     ptr=grep_toline(mystdin,"Bcc:");
  691.    if(ptr)
  692.        strcat(bcc,ptr);
  693.     }
  694.  
  695.     if ( argc <= optind && to[0]=='\0') {
  696.             error( EX_USAGE, "No receiver found\n%s",errortext);
  697.     }
  698.  
  699.   /* Print some configs informations */
  700.   if(debug==VERBOSE || debug==YES)
  701.    {
  702.    char *text[2];
  703.    int i;
  704.  
  705.     printf(FONT_BOLD FONT_REV"SMail"FONT_NORM" (%s) © by Ralph-Thomas Außem (aussem@@mavhh.hanse.de)\nbased on Unix smail V2.5 by Christopher Seiwald\ncompiled with SAS/C Version 6.3 on "__DATE__"\n\
  706. "FONT_ULIN"Files:\n"FONT_NORM"\
  707. Passwd-file    : %s\n\
  708. Paths-file     : %s\n\
  709. Log-file       : %s\n\
  710. Sent-log       : %s\n\
  711. Alias-file     : %s\n\
  712. Fullname-file  : %s\n",
  713. prgtype_string,
  714. passwdfile,pathfile,logfile,sentfile,aliasfile,fnlist);
  715.  
  716. switch(routing)
  717. {
  718. case ALWAYS: text[0]="Always";
  719. break;
  720. case REROUTE: text[0]="Reroute";
  721. break;
  722. case JUSTDOMAIN: text[0]="Just Domain";
  723. break;
  724. }
  725.  
  726. switch(handle)
  727. {
  728. case ALL: text[1]="All";
  729. break;
  730. case JUSTUUCP: text[1]="Just UUCP";
  731. break;
  732. case NONE: text[1]="None";
  733. break;
  734. }
  735.  
  736. printf(FONT_ULIN"Options:\n"FONT_NORM"\
  737. BSMTP          : %s\n\
  738. RMail mode     : %s\n\
  739. Rerouting      : %s\n\
  740. Handle         : %s\n\
  741. Getcost        : %s\n",
  742. bsmtp?"Yes":"No",
  743. asrmail?"Yes":"No",
  744. text[0],text[1],((getcost==1)?"Yes":"No"));
  745.  
  746. printf("To             : ");
  747. for(i=optind;i<argc;i++)printf("%s ",argv[i]);
  748. if(to[0]!='\0')
  749.     printf(" '%s'",to);
  750. printf("\n");
  751.  
  752. if(cc[0]!='\0')
  753.     printf("Cc             : '%s'\n",cc);
  754.  
  755. if(bcc[0]!='\0')
  756.     printf("Bcc            : '%s'\n",bcc);
  757.     }
  758.  
  759. /*
  760. **  Add the -t, -c addresses and To: lines to argv[]
  761. */
  762. if(to[0]!='\0')
  763.     {
  764.    to_argv=mk_argv(to,&to_argc);
  765.     }
  766.  
  767. if(cc[0]!='\0')
  768.     {
  769.    cc_argv=mk_argv(cc,&cc_index);
  770.    }
  771.  
  772. if(bcc[0]!='\0')
  773.     {
  774.    bcc_argv=mk_argv(bcc,&bcc_index);
  775.    }
  776.  
  777. if(to_argv)
  778.        {
  779.       argv=cp_argv(argv,to_argv,argc,to_argc);
  780.       argc+=to_argc;
  781.        }
  782.  
  783. if(cc_argv)
  784.        {
  785.       argv=cp_argv(argv,cc_argv,argc,cc_index);
  786.       argc+=cc_index;
  787.       /* to lousy to create a new variable to store the contents of argc */
  788.       cc_index=argc-cc_index-optind;
  789.        }
  790.  
  791. if(bcc_argv)
  792.        {
  793.       argv=cp_argv(argv,bcc_argv,argc,bcc_index);
  794.       argc+=bcc_index;
  795.       /* to lousy to create a new variable to store the contents of argc */
  796.       bcc_index=argc-bcc_index-optind;
  797.        }
  798.  
  799. /*
  800. **  Spool the letter in a temporary file.
  801. */
  802.     nargc = argc - optind;
  803.     if(printaddr == 0) {
  804.         spool(nargc, &argv[optind]);
  805.     }
  806.  
  807. /*
  808. ** Do aliasing and fullname resolution
  809. */
  810.     nargv = alias(&nargc, &argv[optind]);
  811.  
  812. /*
  813. **  Map argv addresses to <host, user, form, cost>.
  814. */
  815.     map(nargc, nargv, hostv, userv, formv, costv);
  816. /*
  817. **  If all we want it mapped addresses, print them and exit.
  818. */
  819.     if(printaddr) {
  820.         int i;
  821.         char abuf[SMLBUF];
  822.         for(i=nargc-1; i >= 0; i--) {
  823.             if(formv[i] == ERROR) {
  824.                 (void) strcpy(abuf, nargv[i]);
  825.             } else {
  826.                 build(hostv[i], userv[i], formv[i], abuf);
  827.             }
  828.             (void) fputs(abuf, stdout);
  829.             if(i != 0) (void) putchar(' ');
  830.         }
  831.         (void) putchar('\n');
  832.         exit(0);
  833.     }
  834. /*
  835. **  Deliver.
  836. */
  837.   if(return_receipt[0]!='\0')
  838.       {
  839.    print_error(NOTICE,"Recepient-Return-To: %s",return_receipt);
  840.    }
  841.  
  842.     deliver(nargc, hostv, userv, formv, costv);
  843. /*
  844. **  Exitstat was set if any resolve or deliver failed, otherwise 0.
  845. */
  846.     return( exitstat );
  847. }
  848.  
  849. /*
  850. **
  851. **  Generate an argv from an blank seperated line
  852. **
  853. **
  854. */
  855. static char **mk_argv(char *line,int *argc)
  856. {
  857. register int j;
  858. int count;
  859. char *start,
  860.      *end,**argv;
  861.  
  862. *argc = 0;
  863. if(!line)return(NULL);
  864.  
  865. for(start=line;*start==' ';start++);
  866. if(*start=='\0')return(NULL);
  867.  
  868. for(count=1;;)
  869.     {
  870.    end=strchr(start,' ');
  871.    if(!end)break;
  872.    /* skip blankes */
  873.    for(end++;*end==' ';end++);
  874.     if(*end=='\0')break;
  875.    start=end;
  876.    count++;
  877.    }
  878.  
  879. argv=(char **)malloc(count*sizeof(char *));
  880. if(!argv)return(NULL);
  881.  
  882. for(start=line,j=0;j<count;j++)
  883.     {
  884.    end=strchr(start,' ');
  885.    if(end)
  886.           *end='\0';
  887.    argv[j]=strdup(start);
  888.    if(!end)break;
  889.    /* skip blankes */
  890.    for(end++;*end==' ';end++);
  891.     if(*end=='\0')break;
  892.    start=end;
  893.    }
  894. *argc=j+1;
  895. return(argv);
  896. }
  897.  
  898. /*
  899. **
  900. ** concat two argvs
  901. **
  902. */
  903. static char **cp_argv(char **argv1,char **argv2,int argc1,int argc2)
  904. {
  905. register int i;
  906. int sum=argc1+argc2;
  907. char **argv;
  908.  
  909. argv=(char **)malloc(sum*sizeof(char *));
  910. if(!argv)
  911.     {
  912.     print_error(FATAL,"no memory");
  913.     return(NULL);
  914.    }
  915. for(i=0;i<argc1;i++)
  916.     {
  917.     argv[i]=strdup(argv1[i]);
  918.     }
  919. for(i=0;i<argc2;i++)
  920.     {
  921.     argv[i+argc1]=strdup(argv2[i]);
  922.     if(argv2[i])free(argv2[i]);
  923.     }
  924. return(argv);
  925. }
  926.  
  927. @
  928.  
  929.  
  930. 1.29
  931. log
  932. @getmynames() is now start nearly at the start of smail
  933. the batch/unbatch BSMTP functions are now in bsmtp.c
  934. @
  935. text
  936. @d25 4
  937. d127 1
  938. a127 1
  939. static char     *rcsid="$Id: main.c,v 1.28 1993/11/20 23:52:30 Aussem Exp Aussem $";
  940. @
  941.  
  942.  
  943. 1.28
  944. log
  945. @changes output for BSMTP de/batching
  946. @
  947. text
  948. @d25 3
  949. d123 1
  950. a123 1
  951. static char     *rcsid="$Id: main.c,v 1.27 1993/11/20 23:28:53 Aussem Exp Aussem $";
  952. d287 3
  953. a289 1
  954.    /* install atexit() fkt */
  955. d292 3
  956. a294 1
  957.    /* setup external libraries */
  958. d298 3
  959. a300 1
  960.    /* get the program type */
  961. d305 5
  962. d469 1
  963. d472 1
  964. a472 42
  965.    FILE *fp;
  966.    char *cmd;
  967.  
  968.    if(spoolfile)
  969.    {
  970.           switch(tolower(argv0[1]))
  971.           {
  972.           case 'c':
  973.        cmd=get_config("Compress","compress",2);
  974.        if(cmd)
  975.             uncompress_file(spoolfile , cmd);
  976.       else
  977.             uncompress_file(spoolfile , "compress");
  978.         break;
  979.           case 'f':
  980.        cmd=get_config("Freeze","freeze",2);
  981.        if(cmd)
  982.             uncompress_file(spoolfile , cmd);
  983.       else
  984.             uncompress_file(spoolfile , "freeze");
  985.         break;
  986.       }
  987.    fp=fopen(spoolfile,"r");
  988.    convert_smtp(fp);
  989.     }
  990.  
  991.    if(stdin)
  992.    {
  993.           switch(tolower(argv0[1]))
  994.           {
  995.           case 'c':
  996.        cmd=get_config("Compress","compress",2);
  997.        if(cmd)
  998.             mystdin=uncompress_stream(stdin , cmd);
  999.             break;
  1000.           case 'f':
  1001.        cmd=get_config("Freeze","freeze",2);
  1002.        if(cmd)
  1003.             mystdin=uncompress_stream(stdin , cmd);
  1004.         break;
  1005.       }
  1006.    convert_smtp(mystdin);
  1007. a473 7
  1008.   if(mystdin==NULL)
  1009.       {
  1010.       print_error(FATAL,"failed to uncompress stdin in BSMTP mode\n");
  1011.       exit(10);
  1012.       }
  1013.   exit(0);
  1014.   }
  1015. d478 1
  1016. a478 40
  1017.   char batchname[SMLBUF];
  1018.   char tmpname[SMLBUF];
  1019.   char cmd[SMLBUF];
  1020.   int rc;
  1021.  
  1022.   if(hostname[0]=='\0')
  1023.       {
  1024.    print_error(FATAL,"No host for batching specified (use -h hostname)\n");
  1025.    exit(5);
  1026.    }
  1027.  
  1028.   strcpy(batchname,mkfilename(UUBATCH,hostname));
  1029.   strcpy(tmpname,mkfilename("T:",hostname));
  1030.   rc=access(batchname,R_OK);
  1031.   if(rc!=0)
  1032.       {
  1033.    print_error(NOTICE,"Nothing to queue for %s\n",hostname);
  1034.    exit(5);
  1035.    }
  1036.   sprintf(cmd,"%s <%s >%s",compress,batchname,tmpname);
  1037.   print_error(NOTICE,"compressing: '%s'\n",cmd);
  1038.   rc=system(cmd);
  1039.   if(rc)
  1040.       {
  1041.    print_error(FATAL,"unable to compress batch-file %s ('%s')\n",batchname,cmd);
  1042.    exit(10);
  1043.    }
  1044.  
  1045.   sprintf(cmd,"%s %s \"%s!%s\"",UUX,tmpname,hostname,rsmtp_cmd);
  1046.   print_error(NOTICE,"delivering: '%s'\n",cmd);
  1047.   rc=system(cmd);
  1048.   if(rc)
  1049.       {
  1050.    print_error(FATAL,"unable to deliver batch-file %s ('%s')\n",batchname,cmd);
  1051.    exit(10);
  1052.    }
  1053.  
  1054.   remove(tmpname);
  1055.   remove(batchname);
  1056.   exit(0);
  1057. a623 5
  1058.  
  1059. /*
  1060. **  Get our default hostname and hostdomain.
  1061. */
  1062.     getmynames();
  1063. @
  1064.  
  1065.  
  1066. 1.27
  1067. log
  1068. @SMDebug works now
  1069. smail now detects if the user forget to specified a host in BSMTP batch mode
  1070. @
  1071. text
  1072. @d25 4
  1073. d120 1
  1074. a120 1
  1075. static char     *rcsid="$Id: main.c,v 1.26 1993/11/20 22:20:50 Aussem Exp Aussem $";
  1076. d310 1
  1077. a310 1
  1078.     if(stricmp(argv[0],rmailname)!=0 ) {
  1079. d316 1
  1080. a316 1
  1081.     if(stricmp(argv[0],"rsmtp")==0 )
  1082. d321 1
  1083. a321 1
  1084.     if(stricmp(argv[0],"rfsmtp")==0 )
  1085. d326 1
  1086. a326 1
  1087.     if(stricmp(argv[0],"rcsmtp")==0 )
  1088. d462 1
  1089. a462 1
  1090.           switch(tolower(argv[0][1]))
  1091. d485 1
  1092. a485 1
  1093.           switch(tolower(argv[0][1]))
  1094. d502 1
  1095. a502 1
  1096.       print_error(FATAL,"%s: failed to uncompress stdin in BSMTP mode\n",argv[0]);
  1097. d535 1
  1098. a535 1
  1099.    print_error(FATAL,"%s: unable to compress batch-file %s ('%s')\n",argv[0],batchname,cmd);
  1100. d544 1
  1101. a544 1
  1102.    print_error(FATAL,"%s: unable to deliver batch-file %s ('%s')\n",argv[0],batchname,cmd);
  1103. @
  1104.  
  1105.  
  1106. 1.26
  1107. log
  1108. @extended log output
  1109. @
  1110. text
  1111. @d25 3
  1112. d116 1
  1113. a116 1
  1114. static char     *rcsid="$Id: main.c,v 1.25 1993/11/19 00:11:29 Aussem Exp Aussem $";
  1115. d340 1
  1116. a340 1
  1117.    if(get_config("SMDebug","0",1))
  1118. d504 1
  1119. d507 2
  1120. a508 2
  1121.   char batchname[SMLBUF]=UUBATCH;
  1122.   char tmpname[SMLBUF]="T:";
  1123. d512 8
  1124. a519 2
  1125.   strcat(batchname,hostname);
  1126.   strcat(tmpname,hostname);
  1127. d523 1
  1128. a523 1
  1129.    print_error(FATAL,"no batch-file for %s ('%s')\n",hostname,batchname);
  1130. @
  1131.  
  1132.  
  1133. 1.25
  1134. log
  1135. @*** empty log message ***
  1136. @
  1137. text
  1138. @d25 3
  1139. d113 1
  1140. a113 1
  1141. static char     *rcsid="$Id: main.c,v 1.24 1993/11/18 23:16:34 Aussem Exp Aussem $";
  1142. a125 6
  1143.  
  1144. #define FONT_REV        "\033[7m"        /* font reverse */
  1145. #define FONT_ULIN        "\033[4m"        /* font underline */
  1146. #define FONT_BOLD        "\033[1m"        /* font bold */
  1147. #define FONT_NORM        "\033[0m"        /* font normal */
  1148.  
  1149. d132 1
  1150. d202 1
  1151. d286 1
  1152. d297 1
  1153. a297 1
  1154.       printf("%s: WARNING ! you call smail with the unsupported and ignored -raw option\n",argv[0]);
  1155. d338 2
  1156. a339 1
  1157.        debug=VERBOSE;
  1158. d414 2
  1159. a415 2
  1160.         case 'd': debug      = YES;         break;
  1161.         case 'v': debug      = VERBOSE;     break;
  1162. d495 1
  1163. a495 1
  1164.       printf("%s: failed to uncompress stdin in BSMTP mode\n",argv[0]);
  1165. d513 1
  1166. a513 1
  1167.    ADVISE("%s: no batch-file for %s ('%s')\n",argv[0],hostname,batchname);
  1168. d517 1
  1169. a517 1
  1170.   ADVISE("compressing: '%s'\n",cmd);
  1171. d521 1
  1172. a521 1
  1173.    printf("%s: unable to compress batch-file %s ('%s')\n",argv[0],batchname,cmd);
  1174. d526 1
  1175. a526 1
  1176.   ADVISE("delivering: '%s'\n",cmd);
  1177. d530 1
  1178. a530 1
  1179.    printf("%s: unable to deliver batch-file %s ('%s')\n",argv[0],batchname,cmd);
  1180. d726 1
  1181. a726 1
  1182.   if((debug==VERBOSE || debug==YES) && return_receipt[0]!='\0')
  1183. d728 1
  1184. a728 1
  1185.    printf("Recepient-Return-To: %s\n",return_receipt);
  1186. d799 5
  1187. d811 1
  1188. a811 1
  1189.     free(argv2[i]);
  1190. @
  1191.  
  1192.  
  1193. 1.24
  1194. log
  1195. @function call for get_config() changed
  1196. setup_external() insert for open/allocating MUFS/Netsupport library
  1197. @
  1198. text
  1199. @d25 4
  1200. d110 1
  1201. a110 1
  1202. static char     *rcsid="$Id: main.c,v 1.23 1993/11/13 22:13:10 Aussem Exp Aussem $";
  1203. d134 1
  1204. a274 1
  1205.     extern char prgtype_string[];
  1206. @
  1207.  
  1208.  
  1209. 1.23
  1210. log
  1211. @VERSION integrated
  1212. @
  1213. text
  1214. @d25 3
  1215. d106 1
  1216. a106 1
  1217. static char     *rcsid="$Id: main.c,v 1.22 1993/11/13 21:17:19 Aussem Exp Aussem $";
  1218. a259 1
  1219.    char *get_config(char *,short);
  1220. d272 1
  1221. d277 4
  1222. d324 1
  1223. a324 1
  1224.    p=get_config("SMBsmtpSites",2);
  1225. d327 1
  1226. a327 1
  1227.    p=get_config("SMBsmtpCmd",2);
  1228. d330 1
  1229. a330 1
  1230.    p=get_config("SMCompress",2);
  1231. d333 1
  1232. a333 1
  1233.    if(get_config("SMDebug",1))
  1234. d335 1
  1235. a335 1
  1236.    p=get_config("MaxRMailLen",2);
  1237. d338 1
  1238. a338 1
  1239.    p=get_config("SMRerouting",2);
  1240. d350 1
  1241. a350 1
  1242.    p=get_config("SMHandle",2);
  1243. d362 1
  1244. a362 1
  1245.    if(get_config("SMGetcost",0))
  1246. d366 1
  1247. a366 1
  1248.    if(get_config("SMReceipt",0))
  1249. d370 1
  1250. a370 1
  1251.    if(get_config("SMCheckuser",0))
  1252. d372 3
  1253. a374 1
  1254.    p=get_config("SMCheckfile",2);
  1255. d377 1
  1256. a377 1
  1257.    p=get_config("SMLogfile",2);
  1258. d380 1
  1259. a380 1
  1260.    p=get_config("SMMaillogfile",2);
  1261. d383 1
  1262. a383 1
  1263.    p=get_config("SMPasswd",2);
  1264. d386 1
  1265. a386 1
  1266.    p=get_config("SMSentlog",2);
  1267. d389 1
  1268. a389 1
  1269.    p=get_config("SMFullname",2);
  1270. d392 1
  1271. a392 1
  1272.    p=get_config("SMPath",2);
  1273. d395 1
  1274. a395 1
  1275.    p=get_config("SMAlias",2);
  1276. d398 1
  1277. a398 1
  1278.    p=get_config("Sendmail",2);
  1279. d401 1
  1280. a401 1
  1281.    p=get_config("Rmail",2);
  1282. d453 1
  1283. a453 1
  1284.        cmd=get_config("Compress",2);
  1285. d460 1
  1286. a460 1
  1287.        cmd=get_config("Freeze",2);
  1288. d476 1
  1289. a476 1
  1290.        cmd=get_config("Compress",2);
  1291. a478 2
  1292.         else
  1293.             mystdin=uncompress_stream(stdin , "compress");
  1294. d481 1
  1295. a481 1
  1296.        cmd=get_config("Freeze",2);
  1297. a483 2
  1298.       else
  1299.             mystdin=uncompress_stream(stdin , "freeze");
  1300. @
  1301.  
  1302.  
  1303. 1.22
  1304. log
  1305. @changes getversion to get_programtype()
  1306. take rmail name from uulib:config
  1307. @
  1308. text
  1309. @d25 4
  1310. d103 1
  1311. a103 3
  1312. static char     *rcsid="$Id: main.c,v 1.21 1993/11/09 22:41:53 Aussem Exp Aussem $";
  1313.  
  1314. static const char *version="$VER: SMail V1.0 Amiga Version ("__DATE__","__TIME__")";
  1315. d116 1
  1316. d121 3
  1317. @
  1318.  
  1319.  
  1320. 1.21
  1321. log
  1322. @cosmetic changes
  1323. @
  1324. text
  1325. @d25 3
  1326. d99 1
  1327. a99 1
  1328. static char     *rcsid="$Id: main.c,v 1.20 1993/11/04 22:46:25 Aussem Exp Aussem $";
  1329. d188 1
  1330. d262 1
  1331. d265 1
  1332. d268 3
  1333. d286 1
  1334. a286 1
  1335.     if(stricmp(argv[0],"rmail")!=0 ) {
  1336. a319 4
  1337.    p=get_config("Sendmail",2);
  1338.    if(p)
  1339.       strcpy(smailname,p);
  1340.  
  1341. d383 6
  1342. d581 1
  1343. a581 1
  1344. getversion(),
  1345. @
  1346.  
  1347.  
  1348. 1.20
  1349. log
  1350. @smail searches now only to To:/Cc:/Bcc: without a leading space
  1351. @
  1352. text
  1353. @d25 3
  1354. d96 1
  1355. a96 1
  1356. static char     *rcsid="$Id: main.c,v 1.19 1993/11/02 19:57:08 Aussem Exp Aussem $";
  1357. d117 1
  1358. d146 1
  1359. a146 1
  1360.     -C        all mail goes local\n\
  1361. d221 1
  1362. d352 5
  1363. d562 1
  1364. a562 1
  1365.     printf(FONT_BOLD FONT_REV"SMail"FONT_NORM" © by Ralph-Thomas Außem (aussem@@mavhh.hanse.de)\nbased on Unix smail V2.5 by Christopher Seiwald\ncompiled with SAS/C Version 6.3 on "__DATE__"\n\
  1366. d570 1
  1367. d594 2
  1368. d598 4
  1369. a601 1
  1370. Getcost        : %s\n",text[0],text[1],((getcost==1)?"Yes":"No"));
  1371. @
  1372.  
  1373.  
  1374. 1.19
  1375. log
  1376. @atexit() insert
  1377. @
  1378. text
  1379. @d25 3
  1380. d93 1
  1381. a93 1
  1382. static char     *rcsid="$Id: main.c,v 1.18 1993/10/31 21:41:22 Aussem Exp Aussem $";
  1383. d511 1
  1384. a511 1
  1385.         ptr=grep_toline(fp,"To: ");
  1386. d514 1
  1387. a514 1
  1388.         ptr=grep_toline(fp,"Cc: ");
  1389. d517 1
  1390. a517 1
  1391.         ptr=grep_toline(fp,"Bcc: ");
  1392. d531 1
  1393. a531 1
  1394.     ptr=grep_toline(mystdin,"To: ");
  1395. d534 1
  1396. a534 1
  1397.     ptr=grep_toline(mystdin,"Cc: ");
  1398. d537 1
  1399. a537 1
  1400.     ptr=grep_toline(mystdin,"Bcc: ");
  1401. @
  1402.  
  1403.  
  1404. 1.18
  1405. log
  1406. @cosmetic changes
  1407. @
  1408. text
  1409. @d25 3
  1410. d90 1
  1411. a90 1
  1412. static char     *rcsid="$Id: main.c,v 1.17 1993/10/31 21:13:09 Aussem Exp Aussem $";
  1413. d250 3
  1414. @
  1415.  
  1416.  
  1417. 1.17
  1418. log
  1419. @bigger stack size
  1420. @
  1421. text
  1422. @d25 3
  1423. d87 1
  1424. a87 1
  1425. static char     *rcsid="$Id: main.c,v 1.16 1993/10/31 17:50:59 Aussem Exp Aussem $";
  1426. d102 5
  1427. d543 8
  1428. a550 2
  1429.     printf("smail based on smail V2.5 by Christopher Seiwald\nAmiga Port by Ralph-Thomas Außem (aussem@@mavhh.hanse.de)\ncompiled with SAS/C 6.3 on "__DATE__"\n\
  1430. Passwd-file    : %s\t\tPaths-file    : %s\nLog-file    : %s\tSent-log    : %s\nAlias-file    : %s\t\tFullname-file    : %s\n",
  1431. d573 4
  1432. a576 2
  1433. printf("Rerouting    : %s\tHandle    : %s\tGetcost        : %s\n",text[0],text[1],
  1434.                     ((getcost==1)?"Yes":"No"));
  1435. d578 1
  1436. a578 1
  1437. printf("To: ");
  1438. d585 1
  1439. a585 1
  1440.     printf("Cc: '%s'\n",cc);
  1441. d588 1
  1442. a588 1
  1443.     printf("Bcc: '%s'\n",bcc);
  1444. @
  1445.  
  1446.  
  1447. 1.16
  1448. log
  1449. @cosmetic changes in help text
  1450. @
  1451. text
  1452. @d25 3
  1453. d84 1
  1454. a84 1
  1455. static char     *rcsid="$Id: main.c,v 1.15 1993/10/30 23:50:40 Aussem Exp Aussem $";
  1456. d102 1
  1457. a102 1
  1458. long __stack=30000L;
  1459. d565 1
  1460. a565 1
  1461.     printf(" %s",to);
  1462. d569 1
  1463. a569 1
  1464.     printf("Cc: %s\n",cc);
  1465. d572 1
  1466. a572 1
  1467.     printf("Bcc: %s\n",bcc);
  1468. @
  1469.  
  1470.  
  1471. 1.15
  1472. log
  1473. @Version string corrected
  1474. @
  1475. text
  1476. @d25 3
  1477. d81 1
  1478. a81 1
  1479. static char     *rcsid="$Id: main.c,v 1.14 1993/10/30 23:49:15 Aussem Exp Aussem $";
  1480. d126 2
  1481. a127 2
  1482.     -r    running in rmail mode\n\
  1483.     -M     don't return mails, if we can't deliver them\n\
  1484. @
  1485.  
  1486.  
  1487. 1.14
  1488. log
  1489. @stack size via __stacksize set to 20000 bytes
  1490. Version string updated
  1491. @
  1492. text
  1493. @d25 4
  1494. d78 1
  1495. a78 1
  1496. static char     *rcsid="$Id: main.c,v 1.13 1993/10/23 22:47:51 Aussem Exp Aussem $";
  1497. d80 1
  1498. a80 1
  1499. static const char *version="$VER: SMail V1.0 Amiga Version ("__DATE__,__TIME__")";
  1500. @
  1501.  
  1502.  
  1503. 1.13
  1504. log
  1505. @the file for bsmtp options are taken from uulib:config
  1506. @
  1507. text
  1508. @d25 3
  1509. d74 1
  1510. a74 1
  1511. static char     *rcsid="$Id: main.c,v 1.12 1993/10/18 20:38:27 Aussem Exp Aussem $";
  1512. d76 1
  1513. a76 1
  1514. static const char *version="$VER: SMail V2.5 Amiga Version compiled on "__DATE__;
  1515. d90 3
  1516. @
  1517.  
  1518.  
  1519. 1.12
  1520. log
  1521. @batch option implemtended
  1522. @
  1523. text
  1524. @d25 3
  1525. d71 1
  1526. a71 1
  1527. static char     *rcsid="$Id: main.c,v 1.11 1993/10/17 21:12:27 Aussem Exp Aussem $";
  1528. d151 1
  1529. d217 2
  1530. d225 12
  1531. d264 9
  1532. d446 1
  1533. a446 1
  1534.   sprintf(cmd,"%s <%s >%s","compress",batchname,tmpname);
  1535. d455 1
  1536. a455 1
  1537.   sprintf(cmd,"%s %s \"%s!%s\"",UUX,tmpname,hostname,"rcsmtp");
  1538. d519 1
  1539. a519 1
  1540.     printf("smail V2.5 Originaly by Christopher Seiwald\nAmiga Port by Ralph-Thomas Außem (aussem@@mavhh.hanse.de)\ncompiled with SAS/C 6.3 on "__DATE__"\n\
  1541. @
  1542.  
  1543.  
  1544. 1.11
  1545. log
  1546. @compress and freeze commands are taken from uulib:config (if present)
  1547. smail converts the smtp mail to "normal" format and
  1548. then deliver via rmail
  1549. @
  1550. text
  1551. @d25 5
  1552. d68 1
  1553. a68 1
  1554. static char     *rcsid="$Id: main.c,v 1.10 1993/10/17 18:42:34 Aussem Exp Aussem $";
  1555. d93 2
  1556. a94 1
  1557.     -d         debug - verbose and don't invoke mailers.\n\
  1558. d212 1
  1559. d214 1
  1560. a214 1
  1561.     char *optstr = "BCdvArMoOlLH:h:c:b:p:u:q:a:n:m:F:f:s:t:R:";
  1562. d312 1
  1563. d404 37
  1564. @
  1565.  
  1566.  
  1567. 1.10
  1568. log
  1569. @reading a file with -f works now
  1570. uncompressing a mail, if the programs is rfsmtp or rcsmtp works
  1571. @
  1572. text
  1573. @d25 4
  1574. d63 1
  1575. a63 1
  1576. static char     *rcsid="$Id: main.c,v 1.9 1993/10/16 14:56:33 Aussem Exp Aussem $";
  1577. d341 3
  1578. d349 4
  1579. d354 1
  1580. a354 1
  1581.             break;
  1582. d356 4
  1583. d361 1
  1584. a361 1
  1585.             break;
  1586. d363 2
  1587. d366 1
  1588. d372 4
  1589. d379 4
  1590. d384 1
  1591. a384 1
  1592.             break;
  1593. d386 1
  1594. d390 1
  1595. a390 1
  1596.       printf("%s: failed to uncompress stdin in bsmtp mode\n",argv[0]);
  1597. d393 1
  1598. @
  1599.  
  1600.  
  1601. 1.9
  1602. log
  1603. @-M option implemented
  1604. @
  1605. text
  1606. @d25 3
  1607. d59 1
  1608. a59 1
  1609. static char     *rcsid="$Id: main.c,v 1.8 1993/10/10 19:32:34 Aussem Exp Aussem $";
  1610. d87 1
  1611. d172 2
  1612. d203 1
  1613. a203 1
  1614.     char *optstr = "CdvArMoOlLH:h:c:b:p:u:q:a:n:m:F:f:s:t:R:";
  1615. d210 1
  1616. a210 2
  1617.     p=argv[0];
  1618.     if(*p != 'r' ) {
  1619. d216 16
  1620. d300 1
  1621. d335 34
  1622. d370 2
  1623. a371 2
  1624.      rmail mode and fnlist!=NULL */
  1625.   if(fnlist && !asrmail)
  1626. d374 1
  1627. a374 1
  1628.     FILE *fp=fopen(fnlist,"r");
  1629. d393 2
  1630. a394 2
  1631.      rmail mode and stdin!=NULL */
  1632.   if(stdin && !asrmail)
  1633. d398 1
  1634. a398 1
  1635.     ptr=grep_toline(stdin,"To: ");
  1636. d401 1
  1637. a401 1
  1638.     ptr=grep_toline(stdin,"Cc: ");
  1639. d404 1
  1640. a404 1
  1641.     ptr=grep_toline(stdin,"Bcc: ");
  1642. @
  1643.  
  1644.  
  1645. 1.8
  1646. log
  1647. @Bcc: lines are now supported
  1648. @
  1649. text
  1650. @d25 3
  1651. d56 1
  1652. a56 1
  1653. static char     *rcsid="$Id: main.c,v 1.7 1993/09/29 13:14:46 Aussem Exp Aussem $";
  1654. d97 1
  1655. d149 3
  1656. a151 3
  1657. int  queuecost  = QUEUECOST;    /* or set by -q                */
  1658. char *from_addr = NULL;        /* or set by -F                */
  1659. int  maxnoqueue = MAXNOQUEUE;    /* or set by -m                         */
  1660. d153 1
  1661. d197 1
  1662. a197 1
  1663.     char *optstr = "CdvAroOlLH:h:c:b:p:u:q:a:n:m:F:f:s:t:R:";
  1664. d288 1
  1665. @
  1666.  
  1667.  
  1668. 1.7
  1669. log
  1670. @If smail calls smail again, it uses first the uulib:config entry for Sendmail
  1671. and if not exists sendmail
  1672. @
  1673. text
  1674. @d25 4
  1675. d53 1
  1676. a53 1
  1677. static char     *rcsid="$Id: main.c,v 1.6 1993/09/18 20:23:05 Aussem Exp Aussem $";
  1678. d102 1
  1679. d122 4
  1680. a125 3
  1681. int  cc_index    = -1;         /* index starting cc: in the to-arguments */
  1682. char *subject    = NULL;          /* subject of the mail         */
  1683. char *realname   = NULL;       /* realname of the user    */
  1684. d127 1
  1685. a127 1
  1686. char *uuxargs    = NULL;           /* or set by -u                */
  1687. d181 1
  1688. d189 1
  1689. a189 1
  1690.     char **to_argv=NULL,**cc_argv=NULL;
  1691. d192 1
  1692. a192 1
  1693.     char *optstr = "CdvAroOlLH:h:c:p:u:q:a:n:m:F:f:s:t:R:";
  1694. d291 1
  1695. d322 3
  1696. d342 3
  1697. d392 3
  1698. d410 5
  1699. d427 8
  1700. @
  1701.  
  1702.  
  1703. 1.6
  1704. log
  1705. @the cc line can now be parsed from cmdline and from file
  1706. @
  1707. text
  1708. @d25 3
  1709. d49 1
  1710. a49 1
  1711. static char     *rcsid="$Id: main.c,v 1.5 1993/09/18 16:47:47 Aussem Exp Aussem $";
  1712. d123 1
  1713. d200 1
  1714. a200 1
  1715. **  Process command line arguments
  1716. d202 3
  1717. @
  1718.  
  1719.  
  1720. 1.5
  1721. log
  1722. @insert GNU license text in the header
  1723. @
  1724. text
  1725. @d25 3
  1726. d46 1
  1727. a46 1
  1728. static char     *rcsid="$Id: main.c,v 1.4 1993/09/13 22:23:09 Aussem Exp Aussem $";
  1729. d301 1
  1730. a301 1
  1731.         ptr=grep_toline(fp);
  1732. d304 3
  1733. d318 1
  1734. a318 1
  1735.     ptr=grep_toline(stdin);
  1736. d321 3
  1737. @
  1738.  
  1739.  
  1740. 1.4
  1741. log
  1742. @test whether MaxRMailLen exists and set the global variable
  1743. @
  1744. text
  1745. @d10 14
  1746. d25 3
  1747. d43 1
  1748. a43 1
  1749. static char     *rcsid="$Id: main.c,v 1.3 1993/09/12 14:35:49 Aussem Exp Aussem $";
  1750. @
  1751.  
  1752.  
  1753. 1.3
  1754. log
  1755. @SMDebug != 0 will activate verbose output
  1756. @
  1757. text
  1758. @d11 3
  1759. d26 1
  1760. a26 1
  1761. static char     *rcsid="$Id: main.c,v 1.2 1993/09/10 01:54:39 Aussem Exp Aussem $";
  1762. d94 6
  1763. a99 5
  1764. int  cc_index   = -1;         /* index starting cc: in the to-arguments */
  1765. char *subject   = NULL;          /* subject of the mail         */
  1766. char *realname  = NULL;       /* realname of the user    */
  1767. char *pathfile  = PATHS;       /* or set by -p             */
  1768. char *uuxargs   = NULL;           /* or set by -u                */
  1769. d181 3
  1770. @
  1771.  
  1772.  
  1773. 1.2
  1774. log
  1775. @new support for grepping the To: line from mailbody with grep_toline()
  1776. for new support for wCNews styled logfile cmd-line options enabled
  1777. and rmail check (only if we are not rmail grep the To: line)
  1778. react as rmail can be enabled via -r cmd-line option
  1779. @
  1780. text
  1781. @d11 6
  1782. d23 1
  1783. a23 1
  1784. static char     *rcsid="$Id: main.c,v 1.1 1993/09/08 16:27:13 Aussem Exp Aussem $";
  1785. d176 1
  1786. a176 1
  1787.        debug=YES;
  1788. @
  1789.  
  1790.  
  1791. 1.1
  1792. log
  1793. @Initial revision
  1794. @
  1795. text
  1796. @d10 3
  1797. a12 1
  1798.  * $Log$
  1799. d14 1
  1800. d17 1
  1801. a17 1
  1802. static char     *rcsid="$Id$";
  1803. d57 1
  1804. d80 1
  1805. d151 1
  1806. a151 1
  1807.     char *optstr = "CdvAoOlLH:h:c:p:u:q:a:n:m:F:f:s:t:R:";
  1808. d206 3
  1809. d235 1
  1810. d258 29
  1811. d291 1
  1812. a291 1
  1813.  
  1814. d335 1
  1815. a335 1
  1816. **  Add the -t and -c addresses to the argv
  1817. d425 1
  1818. a425 1
  1819. int count=0;
  1820. d429 1
  1821. a429 1
  1822. *argc = count = 0;
  1823. d432 2
  1824. a433 2
  1825. start=stpblk(line);
  1826. if(!start)return(NULL);
  1827. d435 1
  1828. a435 1
  1829. for(;;)
  1830. d438 5
  1831. a443 3
  1832.    if(!end)break;
  1833.    if(*(end+1)=='\0')break;
  1834.    start=end+1;
  1835. d449 1
  1836. a449 2
  1837. start=stpblk(line);
  1838. for(j=0;j<count;j++)
  1839. d453 1
  1840. a453 1
  1841.        *end='\0';
  1842. d455 5
  1843. a459 1
  1844.    start=end+1;
  1845. d461 1
  1846. a461 1
  1847. *argc=count;
  1848. @
  1849.